package org.erp.product.infrastructure.convert;

import org.erp.product.domain.bo.ConnectActionBo;
import org.erp.product.domain.dto.*;
import org.erp.product.domain.entity.ConnectLog;
import org.erp.product.domain.entity.ProductInfo;
import org.erp.product.domain.bo.CallbackBo;
import org.erp.product.domain.bo.ConnectLogQueryBo;
import org.erp.product.domain.bo.TransferBo;
import org.erp.product.domain.vo.ConnectLogVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * 仓库调拨实体转换
 *
 * @author libin
 * @version 1.0
 * @description: 仓库调拨实体转换
 * @date 2025/11/14 14:19
 **/
@Mapper(componentModel = "spring")
public interface ConnectConvert {

    @Mappings(value = {})
    ConnectLogQueryDto boConvertDto(ConnectLogQueryBo connectLogQueryBo);

    @Mappings(value = {
            @Mapping(target = "dickerDtoList", source = "dickerBoList")
    })
    TransferDto boConvertDto(TransferBo transferBo);

    @Mappings(value = {
            @Mapping(target = "connectLogAddDtoList", source = "connectLogAddBoList")
    })
    CallbackDto boConvertDto(CallbackBo callbackBo);

    @Mappings(value = {})
    ConnectActionDto boConvertDto(ConnectActionBo connectActionBo);

    @Mappings(value = {})
    ConnectLogVo convertVo(ConnectLog connectLog);

    @Mappings(value = {
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "createBy", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
            @Mapping(target = "updateBy", ignore = true),
            @Mapping(target = "oldStatus", constant = "-1"),
            @Mapping(target = "newStatus", constant = "0")})
    ConnectLog copyReCreate(ConnectLog connectLog);

    @Mappings(value = {
            @Mapping(target = "stockId", source = "productInfo.stockId"),
            @Mapping(target = "productName", source = "productInfo.productName"),
            @Mapping(target = "productImei", source = "productInfo.productImei"),
            @Mapping(target = "productCode", source = "productInfo.productCode"),
            @Mapping(target = "tenantId", source = "productInfo.tenantId"),
            @Mapping(target = "tenantName", source = "productInfo.tenantName"),
            @Mapping(target = "transferType", source = "connectToInnerAddDto.transferType"),
            @Mapping(target = "operationId", source = "connectToInnerAddDto.operationId"),
            @Mapping(target = "operationName", source = "connectToInnerAddDto.operationName"),
            @Mapping(target = "transferId", source = "connectToInnerAddDto.transferId"),
            @Mapping(target = "transferName", source = "connectToInnerAddDto.transferName"),
            @Mapping(target = "deptId", source = "productInfo.deptId"),
            @Mapping(target = "deptName", source = "productInfo.deptName"),
            @Mapping(target = "costPrice", source = "productInfo.costPrice"),
            @Mapping(target = "dickerPrice", source = "productInfo.dickerPrice"),
            @Mapping(target = "oldStatus", constant = "-1"),
            @Mapping(target = "newStatus", constant = "0")
    })
    ConnectLog dtoConvert(ConnectToInnerAddDto connectToInnerAddDto, ProductInfo productInfo);

    @Mappings(value = {
            @Mapping(target = "stockId",source = "connectLogAddDto.stockId"),
            @Mapping(target = "productName",source = "connectLogAddDto.productName"),
            @Mapping(target = "brandId",source = "connectLogAddDto.brandId"),
            @Mapping(target = "categoryId",source = "connectLogAddDto.categoryId"),
            @Mapping(target = "modelId",source = "connectLogAddDto.modelId"),
            @Mapping(target = "seriesId",source = "connectLogAddDto.seriesId"),
            @Mapping(target = "levelId",source = "connectLogAddDto.levelId"),
            @Mapping(target = "productImei",source = "connectLogAddDto.productImei"),
            @Mapping(target = "productCode",source = "connectLogAddDto.productCode"),
            @Mapping(target = "productColor",source = "connectLogAddDto.productColor"),
            @Mapping(target = "productStorage",source = "connectLogAddDto.productStorage"),
            @Mapping(target = "tenantId",source = "connectLogAddDto.tenantId"),
            @Mapping(target = "tenantName",source = "connectLogAddDto.tenantName"),
            @Mapping(target = "sourceChannel",constant = "0"),
            @Mapping(target = "transferType",source = "callbackDto.transferType"),
            @Mapping(target = "operationId",source = "callbackDto.operationId"),
            @Mapping(target = "operationName",source = "callbackDto.operationName"),
            @Mapping(target = "transferId",source = "callbackDto.transferId"),
            @Mapping(target = "transferName",source = "callbackDto.transferName"),
            @Mapping(target = "deptId",source = "callbackDto.deptId"),
            @Mapping(target = "deptName",source = "callbackDto.deptName"),
            @Mapping(target = "costPrice",source = "connectLogAddDto.costPrice"),
            @Mapping(target = "dickerPrice",source = "connectLogAddDto.dickerPrice"),
            @Mapping(target = "oldStatus",constant = "-1"),
            @Mapping(target = "newStatus",constant = "0"),
            @Mapping(target = "createBy",constant = "0")
    })
    ConnectLog dtoConvert(ConnectLogAddDto connectLogAddDto, CallbackDto callbackDto);
}
